package com.lhx.product.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lhx.product.domain.dto.BrandDTO;
import com.lhx.product.domain.po.BrandPO;
import com.lhx.product.result.PageResult;
import com.lhx.product.result.Result;
import com.lhx.product.result.PageResult;
import com.lhx.product.result.Result;
import com.lhx.product.domain.vo.BrandVO;
import com.lhx.product.mapper.BrandMapper;

import com.lhx.product.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：lihongxiang
 * @Package：com.lhx.product.service.impl
 * @Project：lhx-RuoYi
 * @name：BrandServiceImpl
 * @Date：2024/5/22 下午8:35
 */
@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    /**
     * 功能：添加品牌表
     * @param brandPO
     * @return
     */
    @Override
    public Integer addBrand(BrandPO brandPO) {
        return brandMapper.addBrand(brandPO);
    }

    @Override
    public Result<PageResult<BrandVO>> findBrandList(BrandDTO brandDTO) {
        PageHelper.startPage(brandDTO.getPageNum(),brandDTO.getPageSize());
        List<BrandVO> list=brandMapper.findBrandList(brandDTO);
        PageInfo<BrandVO> brandVOPageInfo = new PageInfo<>(list);
        return PageResult.toResult(brandVOPageInfo.getTotal(),list);
    }

    /**
     * 修改品牌列表信息
     * @param brandPO
     * @return
     */
    @Override
    public Integer updateBrand(BrandPO brandPO) {
        return brandMapper.updateBrand(brandPO);
    }

    /**
     * 删除品牌列表信息
     * @param ids
     * @return
     */
    @Override
    public Integer deleteBrand(Integer[] ids) {
        return brandMapper.deleteBrand(ids);
    }

    /**
     * 批量删除品牌列表信息
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(List<Long> ids) {
        return 0;
    }

    /**
     * 修改品牌列表信息
     * @param ids
     * @param showStatus
     * @return
     */
    @Override
    public int updateShowStatus(List<Long> ids, Integer showStatus) {
        return brandMapper.updateShowStatus(ids,showStatus);
    }

    /**
     * 修改品牌列表信息
     * @param ids
     * @param factoryStatus
     * @return
     */
    @Override
    public int updateFactoryStatus(List<Long> ids, Integer factoryStatus) {
        return brandMapper.updateFactoryStatus(ids,factoryStatus);
    }

    /**
     * 根据id查询品牌列表信息
     * @param id
     * @return
     */
    @Override
    public BrandVO findBrandById(Integer id) {
        return brandMapper.findBrandById(id);
    }


}
